/* Copyright 2008 Bas van den Berg
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef MUDDOOR_H
#define MUDDOOR_H

#include "MudExit.h"
#include "MudOpenable.h"
#include "MudLockable.h"

namespace Chronos {

class MudPlayer;
class Area;

class MudDoor : public MudExit, public MudOpenable {
public:
    MudDoor(const std::string& name_
			, const std::string& descr_
			, Portal* portal_
			, unsigned int closeDelay_);
    virtual void accept(CmdVisitor& v);
    virtual const std::string& getDescription() const;

    virtual void pass(MudPlayer& player);
	virtual void open(MudPlayer& player);
	virtual void close(MudPlayer& player);
    unsigned int reset();
protected:
    virtual void generateDescription();
    bool canOpen(MudPlayer& player);

    std::string customDescription;
	bool changed;
	unsigned int closeDelay;
private:
    MudDoor(const MudDoor& rhs);
    MudDoor& operator=(const MudDoor&);
};


class MudLockedDoor : public MudDoor, public MudLockable {
public:
    MudLockedDoor(const std::string& name_
			, const std::string& descr_
			, Portal* portal_
			, unsigned int closeDelay_);
    virtual void accept(CmdVisitor& v);

	virtual void open(MudPlayer& player);
	virtual void lock(MudPlayer& player, const MudKey& key);
	virtual void unlock(MudPlayer& player, const MudKey& key);

    unsigned int reset();
protected:
    virtual void generateDescription();
private:
//    bool canOpen(MudPlayer& player);

    MudLockedDoor(const MudLockedDoor& rhs);
    MudLockedDoor& operator=(const MudLockedDoor&);
};

}

#endif

